* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Courier New', 'Segoe UI', monospace;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: #0a0a1a;
    color: #00ffea;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 255, 0.1) 0%, transparent 50%),
        linear-gradient(45deg, rgba(10, 10, 26, 0.9), rgba(20, 10, 40, 0.9));
    z-index: -1;
}

/* CRT 扫描线效果 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        transparent 50%,
        rgba(0, 255, 255, 0.03) 51%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9999;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(100vh); }
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #000428 0%, #0a0a1a 30%, #1a0033 100%);
    display: block;
}

.ui-container {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    transform: none;
    width: auto;
    justify-content: flex-end;
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
    z-index: 100;
    pointer-events: none;
}

.ui-container > * {
    pointer-events: auto;
}

.stats {
    background: rgba(0, 10, 30, 0.85);
    padding: 15px 25px;
    border-radius: 8px;
    min-width: 300px;
    border: 1px solid #00ffea;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.3),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    pointer-events: auto;
}

.stats::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #00ffea, #ff00ff, #00ffea);
    border-radius: 10px;
    z-index: -1;
    opacity: 0.5;
}

.stats h3 {
    color: #00ffea;
    margin-bottom: 10px;
    font-size: 1.4rem;
    text-shadow: 0 0 10px #00ffea;
}

.player-info {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
}

.hacker-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #00ffea, #0088ff);
    border-radius: 50%;
    position: relative;
    border: 2px solid #00ffea;
    box-shadow: 0 0 15px #00ffea;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 15px #00ffea; }
    50% { box-shadow: 0 0 25px #00ffea; }
}

.hacker-icon::before,
.hacker-icon::after {
    content: '';
    position: absolute;
    background: #00ffea;
}

.hacker-icon::before {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    top: 12px;
    left: 12px;
    box-shadow: 18px 0 0 #00ffea;
}

.hacker-icon::after {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    bottom: 10px;
    left: 15px;
    box-shadow: 0 0 5px #00ffea;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 1.1rem;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

.data-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.data-icon {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #ffcc00, #ff9900);
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid #ffcc00;
    box-shadow: 0 0 10px #ffcc00;
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.health-bar-container {
    height: 12px;
    width: 200px;
    background: rgba(255, 0, 0, 0.2);
    border-radius: 6px;
    margin: 5px 0;
    overflow: hidden;
    border: 1px solid #00ffea;
}

.health-bar {
    height: 100%;
    background: linear-gradient(to right, #ff0000, #ff9900, #00ff00);
    width: 100%;
    transition: width 0.3s;
    box-shadow: 0 0 10px #00ff00;
}

.game-buttons {
    display: flex;
    flex-direction: row;
    gap: 15px;
    pointer-events: auto;
    justify-content: flex-end;
}

.cyber-btn {
    background: linear-gradient(45deg, #0088ff, #00ffea);
    color: #000;
    border: none;
    padding: 15px 35px;
    font-size: 1.2rem;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
}

.cyber-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: 0.5s;
}

.cyber-btn:hover::before {
    left: 100%;
}

.cyber-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.8),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
}

.start-btn {
    background: linear-gradient(45deg, #00ff88, #00cc66);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.pause-btn {
    background: linear-gradient(45deg, #ff0088, #cc0066);
    box-shadow: 0 0 20px rgba(255, 0, 136, 0.5);
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 10, 30, 0.95);
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    display: none;
    z-index: 1000;
    border: 2px solid #00ffea;
    box-shadow: 
        0 0 50px rgba(0, 255, 255, 0.5),
        inset 0 0 30px rgba(0, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    width: 90%;
    max-width: 500px;
}

.game-over h2 {
    color: #ff0066;
    font-size: 3rem;
    margin-bottom: 20px;
    text-shadow: 0 0 20px #ff0066;
    letter-spacing: 3px;
}

.game-over p {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #00ffea;
}

.tutorial-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 10, 30, 0.9);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 1000;
    border: 2px solid #00ffea;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeOut 3s ease-in-out forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

.tutorial-overlay h3 {
    color: #00ffea;
    margin-bottom: 15px;
    font-size: 1.8rem;
    text-shadow: 0 0 10px #00ffea;
}

.tutorial-overlay p {
    color: #ffffff;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.virtual-controls {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    display: none;                /* 默认隐藏 */
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
    pointer-events: none;
}

.virtual-controls > * {
    pointer-events: auto;
}

/* 虚拟摇杆容器 */
.joystick-container {
    width: 120px;
    height: 120px;
    position: relative;
    touch-action: none;           /* 禁止页面滚动/缩放 */
    z-index: 2000;                /* 确保位于其他元素之上 */
    -webkit-tap-highlight-color: transparent;
}

.joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 50%;
    border: 2px solid rgba(0, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    pointer-events: none;          /* 让触摸事件穿透到底层摇杆thumb？不，我们想让容器接收事件，所以base应设为none，thumb不需要事件 */
}

/* 摇杆thumb不应干扰触摸，它只是视觉元素 */
.joystick-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00ffea, #0088ff);
    border-radius: 50%;
    border: 2px solid #00ffea;
    box-shadow: 0 0 20px #00ffea;
    transition: transform 0.1s;
    pointer-events: none;           /* 确保触摸事件由容器接收，而不是thumb */
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.action-button {
    width: 80px;
    height: 80px;
    background: rgba(255, 0, 136, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 0, 136, 0.5);
    backdrop-filter: blur(5px);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(255, 0, 136, 0.3);
}

.action-button:active {
    transform: scale(0.95);
    background: rgba(255, 0, 136, 0.4);
    box-shadow: 0 0 30px rgba(255, 0, 136, 0.6);
}

.action-button span {
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    text-shadow: 0 0 5px white;
}

.jump-button {
    background: rgba(0, 255, 136, 0.2);
    border-color: rgba(0, 255, 136, 0.5);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.jump-button:active {
    background: rgba(0, 255, 136, 0.4);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.6);
}

/* ========== 旋转提示层 ========== */
.rotate-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.98);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    flex-direction: column;
    color: #00ffea;
    font-family: 'Courier New', monospace;
    border: 2px solid #00ffea;
    box-shadow: 0 0 30px #00ffea;
}

.rotate-content {
    text-align: center;
    padding: 30px;
    border: 1px solid #00ffea;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
}

.rotate-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rotate 2s infinite linear;
}

.rotate-content p {
    font-size: 1.5rem;
    text-shadow: 0 0 10px #00ffea;
}

/* ========== 响应式设计（移动端断点 900px） ========== */
@media (max-width: 900px) {
    /* 竖屏显示旋转提示 */
    .rotate-message {
        display: none;
    }
    @media (orientation: portrait) {
        .rotate-message {
            display: flex;
        }
    }

    /* 隐藏教程浮层 */
    .tutorial-overlay {
        display: none !important;
    }

    /* 紧凑状态卡片 */
    .stats {
        padding: 8px 10px;
        max-width: 260px;
        font-size: 0.8rem;
        min-width: auto;
    }

    .stat-row {
        font-size: 0.75rem;
        margin-bottom: 2px;
        padding: 2px 0;
    }

    .player-info {
        gap: 8px;
        margin-bottom: 5px;
    }

    .hacker-icon {
        width: 30px;
        height: 30px;
    }

    .hacker-icon::before {
        width: 6px;
        height: 6px;
        top: 8px;
        left: 8px;
        box-shadow: 10px 0 0 #00ffea;
    }

    .hacker-icon::after {
        width: 12px;
        height: 3px;
        bottom: 6px;
        left: 9px;
    }

    .health-bar-container {
        width: 120px;
        height: 8px;
    }

    .data-icon {
        width: 20px;
        height: 20px;
        margin-right: 5px;
    }

    .game-buttons .cyber-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    /* 调整 UI 容器为左右分栏布局 */
    .ui-container {
        top: 10px;
        left: 10px;          /* 左侧留边 */
        right: 10px;         /* 右侧留边 */
        width: auto;
        flex-direction: row;        /* 改为水平排列 */
        justify-content: space-between; /* 左右分开 */
        align-items: flex-start;    /* 顶部对齐 */
        gap: 5px;
    }

    /* 状态卡片缩小并固定在左上角 */
    .stats {
        padding: 6px 10px;
        max-width: 150px;           /* 更小的宽度 */
        font-size: 0.7rem;
        min-width: auto;
        margin: 0;
        flex: 0 1 auto;              /* 允许收缩 */
    }

    .stat-row {
        font-size: 0.65rem;
        margin-bottom: 2px;
        padding: 1px 0;
    }

    .player-info {
        gap: 6px;
        margin-bottom: 3px;
    }

    .hacker-icon {
        width: 24px;
        height: 24px;
    }

    .hacker-icon::before {
        width: 5px;
        height: 5px;
        top: 6px;
        left: 6px;
        box-shadow: 8px 0 0 #00ffea;
    }

    .hacker-icon::after {
        width: 10px;
        height: 2px;
        bottom: 5px;
        left: 7px;
    }

    .health-bar-container {
        width: 100px;                /* 适应小卡片 */
        height: 6px;
    }

    .data-icon {
        width: 16px;
        height: 16px;
        margin-right: 3px;
    }

    /* 游戏按钮组固定在右上角 */
    .game-buttons {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-end;
        gap: 8px;
        margin: 0;
    }

    .game-buttons .cyber-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* 虚拟摇杆保持原有样式 */
    .virtual-controls {
        bottom: 20px;
        padding: 0 20px;
    }

    .joystick-container {
        width: 100px;
        height: 100px;
    }

    .joystick-thumb {
        width: 50px;
        height: 50px;
    }

    .action-button {
        width: 70px;
        height: 70px;
    }
}
